# import face_recognition
# import cv2

# # 获取人脸特征点
# image = face_recognition.load_image_file("./unknow_pictures/test.jpg")
# face_landmarks_list = face_recognition.face_landmarks(image)

# # 输出人脸特征点
# # print(face_landmarks_list)

# # 绘制人脸特征点
# for face_landmarks in face_landmarks_list:
#     for facial_feature in face_landmarks.keys():
#         for pt_pos in face_landmarks[facial_feature]:
#                 cv2.circle(image, pt_pos, 1, (255, 0, 0), 2)

       
# # 将图片转换成原来的色彩
# #（因在前面的步骤中face recognition已自动将图片转化成了灰度图）
# image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

#  cv2.imwrite('test.png', testImg,[int(cv2.IMWRITE_PNG_COMPRESSION), 9])
# # 展示图片
# cv2.imshow("picture1 shibie", image_rgb)
# # 等待用户关闭界面
# cv2.waitKey(0)

from PIL import Image, ImageDraw
import face_recognition
 
# Load the jpg file into a numpy array
image = face_recognition.load_image_file("./unknow_pictures/7米.jpg")
 
# Find all facial features in all the faces in the image
face_landmarks_list = face_recognition.face_landmarks(image)
 
print("I found {} face(s) in this photograph.".format(len(face_landmarks_list)))
 
# Create a PIL imagedraw object so we can draw on the picture
pil_image = Image.fromarray(image)
d = ImageDraw.Draw(pil_image)
 
for face_landmarks in face_landmarks_list:
 
    # Print the location of each facial feature in this image
    for facial_feature in face_landmarks.keys():
        print("The {} in this face has the following points: {}".format(facial_feature, face_landmarks[facial_feature]))
 
    # Let's trace out each facial feature in the image with a line!
    for facial_feature in face_landmarks.keys():
        d.line(face_landmarks[facial_feature], width=2)
 
# Show the picture
pil_image.show()